<?php

namespace Apps\Common\Models;

/**
 * 订单商品Model
 * @author     chenxiaolin
 * @date        2016年1月19日
 * @version     2.0.0
 * @copyright   Copyright 2016 meelier.com
 */
class UserOrderGoods extends \PhalconPlus\Database\Model
{

    /**
     *
     * @var integer
     */
    public $order_goods_id;

    /**
     *
     * @var integer
     */
    public $user_id;

    /**
     *
     * @var integer
     */
    public $order_id;

    /**
     *
     * @var integer
     */
    public $shop_id;

    /**
     *
     * @var integer
     */
    public $goods_id;

    /**
     *
     * @var integer
     */
    public $goods_style_id;

    /**
     *
     * @var integer
     */
    public $order_goods_number;

    /**
     *
     * @var double
     */
    public $goods_price;

    /**
     *
     * @var integer
     */
    public $order_goods_state;

    /**
     *
     * @var string
     */
    public $order_goods_addtime;

    /**
     * Initialize method for model.
     */
    public function initialize()
    {
        $this->belongsTo('order_id', 'Apps\Common\Models\UserOrder', 'order_id', array('alias' => 'UserOrder'));
    }

    /**
     * Returns table name mapped in the model.
     *
     * @return string
     */
    public function getSource()
    {
        return 'user_order_goods';
    }

    /**
     * Allows to query a set of records that match the specified conditions
     *
     * @param mixed $parameters
     * @return UserOrderGoods[]
     */
    public static function find($parameters = null)
    {
        return parent::find($parameters);
    }

    /**
     * Allows to query the first record that match the specified conditions
     *
     * @param mixed $parameters
     * @return UserOrderGoods
     */
    public static function findFirst($parameters = null)
    {
        return parent::findFirst($parameters);
    }

    /**
     * Independent Column Mapping.
     * Keys are the real names in the table and the values their names in the application
     *
     * @return array
     */
    public function columnMap()
    {
        return array(
            'order_goods_id' => 'order_goods_id',
            'user_id' => 'user_id',
            'order_id' => 'order_id',
            'shop_id' => 'shop_id',
            'goods_id' => 'goods_id',
            'goods_style_id' => 'goods_style_id',
            'order_goods_number' => 'order_goods_number',
            'goods_price' => 'goods_price',
            'order_goods_state' => 'order_goods_state',
            'order_goods_addtime' => 'order_goods_addtime'
        );
    }

    public function defaultColumns()
    {
        return [
            'shop_id',
            'goods_style_id',
            'order_goods_state',
            'order_pay_state',
            'order_goods_addtime',
        ];
    }

}
